iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 6
0
Software Development

讓模型上雲 - Autodesk Forge API 學習筆記系列 第 6

Day6 - Create forge server (3)-網頁結構雛形

  • 分享至 

  • xImage
  •  

forge viewer的版面主要分成上方的nav-bar,下方左欄與右欄,以及透過按鈕觸發的modal,主要皆以boostrap佈局


首先打開index.html這個檔案,在標籤內填上下述內容

header

使用navbar元件,內部的logo元素靠左

  <nav class="navbar navbar-default navbar-fixed-top">
    <div class="container-fluid">
      <ul class="nav navbar-nav left">
        <li>
          <a href="http://developer.autodesk.com" target="_blank">
            <img alt="Autodesk Forge" src="//developer.static.autodesk.com/images/logo_forge-2-line.png" height="20">
          </a>
        </li>
      </ul>
    </div>
  </nav>

content

主要欄位以boostrap的grid system佈局,首先外層以container包住所有元素,加上fluid指定container會完整打滿整個視窗畫面。

  • col-sm-4col-sm-8分別指定了容器樹與viewer的畫面比例。
  • 按鈕元素(id="showFormCreateBucket")透過data-toggle="modal"data-target="#createBucketModal"用於觸發modal的顯示與否
<div class="container-fluid fill">
    <div class="row fill">
      <div class="col-sm-4 fill">
        <div class="panel panel-default fill">
          <div class="panel-heading" data-toggle="tooltip">
            Buckets & Objects
            <span id="refreshBuckets" class="glyphicon glyphicon-refresh" style="cursor: pointer"></span>
            <button class="btn btn-xs btn-info" style="float: right" id="showFormCreateBucket" data-toggle="modal" data-target="#createBucketModal">
              <span class="glyphicon glyphicon-folder-close"></span> New bucket
            </button>
          </div>
          <div id="appBuckets">
            tree here
          </div>
        </div>
      </div>
      <div class="col-sm-8 fill">
        <div id="forgeViewer"></div>
      </div>
    </div>
  </div>
  <form id="uploadFile" method='post' enctype="multipart/form-data">
    <input id="hiddenUploadField" type="file" name="theFile" style="visibility:hidden" />
  </form>

modal

這個modal對應於content中的button(id="showFormCreateBucket")

  <div class="modal fade" id="createBucketModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Cancel">
            <span aria-hidden="true">×</span>
          </button>
          <h4 class="modal-title" id="myModalLabel">Create new bucket</h4>
        </div>
        <div class="modal-body">
          <input type="text" id="newBucketKey" class="form-control"> For demonstration purposes, objects (files)
          are NOT automatically translated. After you upload, right click on
          the object and select "Translate". Note: Technically your bucket name is required to be globally unique across
          the entire platform - to keep things simple with this tutorial your client ID will be prepended by default to
          your bucket name and in turn masked by the UI so you only have to make sure your bucket name is unique within
          your current Forge app.
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
          <button type="button" class="btn btn-primary" id="createNewBucket">Go ahead, create the bucket</button>
        </div>
      </div>
    </div>
  </div>

整個viewer的網頁結構完成至此。


上一篇
Day5-Create forge server (2)
下一篇
Day7-Create forge server (4)-設定環境變數
系列文
讓模型上雲 - Autodesk Forge API 學習筆記12
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言